﻿package org.openChart.sprite.util 
{
	import org.openChart.sprite.elements.Pie3d;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	/**
	 * ...
	 * @author Chongyuan
	 */
	public class AngleHelper 
	{
		private var repeatCount:uint = 100;
		private var target:Pie3d;
		private var beginAngle_:Number;
		private var endAngle_:Number;
		
		public function AngleHelper( target:Pie3d, beginAngle_:Number, endAngle_:Number, time:Number = 5000) 
		{
			this.target = target;
			this.beginAngle_ = beginAngle_;
			this.endAngle_ = endAngle_;
			target.endAngle = beginAngle_;
			var timer:Timer = new Timer( time / 100, repeatCount);
			timer.start();
			timer.addEventListener(TimerEvent.TIMER, onTick);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
		}
		
		public function onTick( event:TimerEvent ):void
		{
			//trace(beginAngle_, endAngle_);
			target.endAngle += (endAngle_ - beginAngle_) / repeatCount;
		}
		
		public function timerComplete( event:TimerEvent ):void
		{
			
		}
	}
	
}